import { createVNode } from 'vue';
import * as $Icon from '@ant-design/icons-vue';

export const Icon = (props: { icon: string }) => {
  const { icon } = props;
  const isValidKey = (
    key: string | number | symbol,
    object: object,
  ): key is keyof typeof object => {
    return key in object;
  };
  if (isValidKey(icon, $Icon)) {
    return createVNode($Icon[icon]);
  }
};
